class Solution:
  def majorityElement(self, nums: list) -> int:
    hash_map = dict()
    for i in range(len(nums)):
      if nums[i] not in hash_map:
        hash_map[nums[i]] = 0
      else:
        hash_map[nums[i]] = hash_map[nums[i]] + 1
    # 通过字典的value寻找对应的key
    res = list(filter(lambda k: hash_map.get(k) >= len(nums) // 2, hash_map))
    return res[0]


'''
STATUS: SOLVED
TRIES:  1
TIME:   60 MS
MEMORY: 15.2 MB
'''
if __name__ == "__main__":
  solution = Solution()
  print(solution.majorityElement([1, 2, 3, 2, 2, 2, 5, 4, 2]))
